/*
 * Copyright (c) 2023, Texas Instruments Incorporated - http://www.ti.com
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * *  Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * *  Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * *  Neither the name of Texas Instruments Incorporated nor the names of
 *    its contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/*
 *  ============ ti_msp_dl_config.h =============
 *  Configured MSPM0 DriverLib module declarations
 *
 *  DO NOT EDIT - This file is generated for the MSPM0G350X
 *  by the SysConfig tool.
 */
#ifndef ti_msp_dl_config_h
#define ti_msp_dl_config_h

#define CONFIG_MSPM0G350X
#define CONFIG_MSPM0G3507

#if defined(__ti_version__) || defined(__TI_COMPILER_VERSION__)
#define SYSCONFIG_WEAK __attribute__((weak))
#elif defined(__IAR_SYSTEMS_ICC__)
#define SYSCONFIG_WEAK __weak
#elif defined(__GNUC__)
#define SYSCONFIG_WEAK __attribute__((weak))
#endif

#include <ti/devices/msp/msp.h>
#include <ti/driverlib/driverlib.h>
#include <ti/driverlib/m0p/dl_core.h>

#ifdef __cplusplus
extern "C" {
#endif

/*
 *  ======== SYSCFG_DL_init ========
 *  Perform all required MSP DL initialization
 *
 *  This function should be called once at a point before any use of
 *  MSP DL.
 */


/* clang-format off */

#define POWER_STARTUP_DELAY                                                (16)



#define CPUCLK_FREQ                                                     80000000



/* Defines for PWM_A */
#define PWM_A_INST                                                         TIMA1
#define PWM_A_INST_IRQHandler                                   TIMA1_IRQHandler
#define PWM_A_INST_INT_IRQN                                     (TIMA1_INT_IRQn)
#define PWM_A_INST_CLK_FREQ                                              1250000
/* GPIO defines for channel 0 */
#define GPIO_PWM_A_C0_PORT                                                 GPIOA
#define GPIO_PWM_A_C0_PIN                                         DL_GPIO_PIN_15
#define GPIO_PWM_A_C0_IOMUX                                      (IOMUX_PINCM37)
#define GPIO_PWM_A_C0_IOMUX_FUNC                     IOMUX_PINCM37_PF_TIMA1_CCP0
#define GPIO_PWM_A_C0_IDX                                    DL_TIMER_CC_0_INDEX

/* Defines for PWM_B */
#define PWM_B_INST                                                         TIMA0
#define PWM_B_INST_IRQHandler                                   TIMA0_IRQHandler
#define PWM_B_INST_INT_IRQN                                     (TIMA0_INT_IRQn)
#define PWM_B_INST_CLK_FREQ                                              1250000
/* GPIO defines for channel 0 */
#define GPIO_PWM_B_C0_PORT                                                 GPIOA
#define GPIO_PWM_B_C0_PIN                                          DL_GPIO_PIN_0
#define GPIO_PWM_B_C0_IOMUX                                       (IOMUX_PINCM1)
#define GPIO_PWM_B_C0_IOMUX_FUNC                      IOMUX_PINCM1_PF_TIMA0_CCP0
#define GPIO_PWM_B_C0_IDX                                    DL_TIMER_CC_0_INDEX



/* Defines for TIMER_0 */
#define TIMER_0_INST                                                     (TIMG0)
#define TIMER_0_INST_IRQHandler                                 TIMG0_IRQHandler
#define TIMER_0_INST_INT_IRQN                                   (TIMG0_INT_IRQn)
#define TIMER_0_INST_LOAD_VALUE                                           (499U)
/* Defines for TIMER_1 */
#define TIMER_1_INST                                                     (TIMG6)
#define TIMER_1_INST_IRQHandler                                 TIMG6_IRQHandler
#define TIMER_1_INST_INT_IRQN                                   (TIMG6_INT_IRQn)
#define TIMER_1_INST_LOAD_VALUE                                            (49U)



/* Defines for UART_0 */
#define UART_0_INST                                                        UART0
#define UART_0_INST_FREQUENCY                                            4000000
#define UART_0_INST_IRQHandler                                  UART0_IRQHandler
#define UART_0_INST_INT_IRQN                                      UART0_INT_IRQn
#define GPIO_UART_0_RX_PORT                                                GPIOA
#define GPIO_UART_0_TX_PORT                                                GPIOA
#define GPIO_UART_0_RX_PIN                                        DL_GPIO_PIN_11
#define GPIO_UART_0_TX_PIN                                        DL_GPIO_PIN_10
#define GPIO_UART_0_IOMUX_RX                                     (IOMUX_PINCM22)
#define GPIO_UART_0_IOMUX_TX                                     (IOMUX_PINCM21)
#define GPIO_UART_0_IOMUX_RX_FUNC                      IOMUX_PINCM22_PF_UART0_RX
#define GPIO_UART_0_IOMUX_TX_FUNC                      IOMUX_PINCM21_PF_UART0_TX
#define UART_0_BAUD_RATE                                                (115200)
#define UART_0_IBRD_4_MHZ_115200_BAUD                                        (2)
#define UART_0_FBRD_4_MHZ_115200_BAUD                                       (11)
/* Defines for UART_WIT */
#define UART_WIT_INST                                                      UART3
#define UART_WIT_INST_FREQUENCY                                         40000000
#define UART_WIT_INST_IRQHandler                                UART3_IRQHandler
#define UART_WIT_INST_INT_IRQN                                    UART3_INT_IRQn
#define GPIO_UART_WIT_RX_PORT                                              GPIOB
#define GPIO_UART_WIT_TX_PORT                                              GPIOA
#define GPIO_UART_WIT_RX_PIN                                      DL_GPIO_PIN_13
#define GPIO_UART_WIT_TX_PIN                                      DL_GPIO_PIN_14
#define GPIO_UART_WIT_IOMUX_RX                                   (IOMUX_PINCM30)
#define GPIO_UART_WIT_IOMUX_TX                                   (IOMUX_PINCM36)
#define GPIO_UART_WIT_IOMUX_RX_FUNC                    IOMUX_PINCM30_PF_UART3_RX
#define GPIO_UART_WIT_IOMUX_TX_FUNC                    IOMUX_PINCM36_PF_UART3_TX
#define UART_WIT_BAUD_RATE                                              (115200)
#define UART_WIT_IBRD_40_MHZ_115200_BAUD                                    (21)
#define UART_WIT_FBRD_40_MHZ_115200_BAUD                                    (45)
/* Defines for UART_1 */
#define UART_1_INST                                                        UART1
#define UART_1_INST_FREQUENCY                                           40000000
#define UART_1_INST_IRQHandler                                  UART1_IRQHandler
#define UART_1_INST_INT_IRQN                                      UART1_INT_IRQn
#define GPIO_UART_1_RX_PORT                                                GPIOA
#define GPIO_UART_1_TX_PORT                                                GPIOA
#define GPIO_UART_1_RX_PIN                                         DL_GPIO_PIN_9
#define GPIO_UART_1_TX_PIN                                         DL_GPIO_PIN_8
#define GPIO_UART_1_IOMUX_RX                                     (IOMUX_PINCM20)
#define GPIO_UART_1_IOMUX_TX                                     (IOMUX_PINCM19)
#define GPIO_UART_1_IOMUX_RX_FUNC                      IOMUX_PINCM20_PF_UART1_RX
#define GPIO_UART_1_IOMUX_TX_FUNC                      IOMUX_PINCM19_PF_UART1_TX
#define UART_1_BAUD_RATE                                                  (9600)
#define UART_1_IBRD_40_MHZ_9600_BAUD                                       (260)
#define UART_1_FBRD_40_MHZ_9600_BAUD                                        (27)




/* Defines for SPI_LCD */
#define SPI_LCD_INST                                                       SPI1
#define SPI_LCD_INST_IRQHandler                                 SPI1_IRQHandler
#define SPI_LCD_INST_INT_IRQN                                     SPI1_INT_IRQn
#define GPIO_SPI_LCD_PICO_PORT                                            GPIOB
#define GPIO_SPI_LCD_PICO_PIN                                     DL_GPIO_PIN_8
#define GPIO_SPI_LCD_IOMUX_PICO                                 (IOMUX_PINCM25)
#define GPIO_SPI_LCD_IOMUX_PICO_FUNC                 IOMUX_PINCM25_PF_SPI1_PICO
#define GPIO_SPI_LCD_POCI_PORT                                            GPIOB
#define GPIO_SPI_LCD_POCI_PIN                                     DL_GPIO_PIN_7
#define GPIO_SPI_LCD_IOMUX_POCI                                 (IOMUX_PINCM24)
#define GPIO_SPI_LCD_IOMUX_POCI_FUNC                 IOMUX_PINCM24_PF_SPI1_POCI
/* GPIO configuration for SPI_LCD */
#define GPIO_SPI_LCD_SCLK_PORT                                            GPIOB
#define GPIO_SPI_LCD_SCLK_PIN                                     DL_GPIO_PIN_9
#define GPIO_SPI_LCD_IOMUX_SCLK                                 (IOMUX_PINCM26)
#define GPIO_SPI_LCD_IOMUX_SCLK_FUNC                 IOMUX_PINCM26_PF_SPI1_SCLK



/* Defines for DMA_WIT */
#define DMA_WIT_CHAN_ID                                                      (1)
#define UART_WIT_INST_DMA_TRIGGER                            (DMA_UART3_RX_TRIG)

/* Defines for DMA_CH0 */
#define DMA_CH0_CHAN_ID                                                      (0)
#define UART_1_INST_DMA_TRIGGER                              (DMA_UART1_RX_TRIG)



/* Port definition for Pin Group LED1 */
#define LED1_PORT                                                        (GPIOB)

/* Defines for PIN_22: GPIOB.22 with pinCMx 50 on package pin 21 */
#define LED1_PIN_22_PIN                                         (DL_GPIO_PIN_22)
#define LED1_PIN_22_IOMUX                                        (IOMUX_PINCM50)
/* Port definition for Pin Group SPI1_CS */
#define SPI1_CS_PORT                                                     (GPIOB)

/* Defines for EEPROM_CS: GPIOB.6 with pinCMx 23 on package pin 58 */
#define SPI1_CS_EEPROM_CS_PIN                                    (DL_GPIO_PIN_6)
#define SPI1_CS_EEPROM_CS_IOMUX                                  (IOMUX_PINCM23)
/* Port definition for Pin Group BUZZER */
#define BUZZER_PORT                                                      (GPIOB)

/* Defines for buzzer: GPIOB.5 with pinCMx 18 on package pin 53 */
#define BUZZER_buzzer_PIN                                        (DL_GPIO_PIN_5)
#define BUZZER_buzzer_IOMUX                                      (IOMUX_PINCM18)
/* Port definition for Pin Group Laser_Relay */
#define Laser_Relay_PORT                                                 (GPIOA)

/* Defines for Laser_IO: GPIOA.18 with pinCMx 40 on package pin 11 */
#define Laser_Relay_Laser_IO_PIN                                (DL_GPIO_PIN_18)
#define Laser_Relay_Laser_IO_IOMUX                               (IOMUX_PINCM40)
/* Defines for KEY_board: GPIOB.21 with pinCMx 49 on package pin 20 */
#define KEY_KEY_board_PORT                                               (GPIOB)
#define KEY_KEY_board_PIN                                       (DL_GPIO_PIN_21)
#define KEY_KEY_board_IOMUX                                      (IOMUX_PINCM49)
/* Defines for KEY1: GPIOB.24 with pinCMx 52 on package pin 23 */
#define KEY_KEY1_PORT                                                    (GPIOB)
#define KEY_KEY1_PIN                                            (DL_GPIO_PIN_24)
#define KEY_KEY1_IOMUX                                           (IOMUX_PINCM52)
/* Defines for KEY2: GPIOA.22 with pinCMx 47 on package pin 18 */
#define KEY_KEY2_PORT                                                    (GPIOA)
#define KEY_KEY2_PIN                                            (DL_GPIO_PIN_22)
#define KEY_KEY2_IOMUX                                           (IOMUX_PINCM47)
/* Defines for KEY3: GPIOB.20 with pinCMx 48 on package pin 19 */
#define KEY_KEY3_PORT                                                    (GPIOB)
#define KEY_KEY3_PIN                                            (DL_GPIO_PIN_20)
#define KEY_KEY3_IOMUX                                           (IOMUX_PINCM48)
/* Defines for KEY4: GPIOA.25 with pinCMx 55 on package pin 26 */
#define KEY_KEY4_PORT                                                    (GPIOA)
#define KEY_KEY4_PIN                                            (DL_GPIO_PIN_25)
#define KEY_KEY4_IOMUX                                           (IOMUX_PINCM55)
/* Defines for KEY5: GPIOB.25 with pinCMx 56 on package pin 27 */
#define KEY_KEY5_PORT                                                    (GPIOB)
#define KEY_KEY5_PIN                                            (DL_GPIO_PIN_25)
#define KEY_KEY5_IOMUX                                           (IOMUX_PINCM56)
/* Port definition for Pin Group LCD */
#define LCD_PORT                                                         (GPIOB)

/* Defines for RES: GPIOB.10 with pinCMx 27 on package pin 62 */
#define LCD_RES_PIN                                             (DL_GPIO_PIN_10)
#define LCD_RES_IOMUX                                            (IOMUX_PINCM27)
/* Defines for DC: GPIOB.11 with pinCMx 28 on package pin 63 */
#define LCD_DC_PIN                                              (DL_GPIO_PIN_11)
#define LCD_DC_IOMUX                                             (IOMUX_PINCM28)
/* Defines for CS: GPIOB.14 with pinCMx 31 on package pin 2 */
#define LCD_CS_PIN                                              (DL_GPIO_PIN_14)
#define LCD_CS_IOMUX                                             (IOMUX_PINCM31)
/* Defines for BLK: GPIOB.26 with pinCMx 57 on package pin 28 */
#define LCD_BLK_PIN                                             (DL_GPIO_PIN_26)
#define LCD_BLK_IOMUX                                            (IOMUX_PINCM57)
/* Port definition for Pin Group ABIN */
#define ABIN_PORT                                                        (GPIOB)

/* Defines for AIN1: GPIOB.27 with pinCMx 58 on package pin 29 */
#define ABIN_AIN1_PIN                                           (DL_GPIO_PIN_27)
#define ABIN_AIN1_IOMUX                                          (IOMUX_PINCM58)
/* Defines for AIN2: GPIOB.23 with pinCMx 51 on package pin 22 */
#define ABIN_AIN2_PIN                                           (DL_GPIO_PIN_23)
#define ABIN_AIN2_IOMUX                                          (IOMUX_PINCM51)
/* Defines for BIN1: GPIOB.2 with pinCMx 15 on package pin 50 */
#define ABIN_BIN1_PIN                                            (DL_GPIO_PIN_2)
#define ABIN_BIN1_IOMUX                                          (IOMUX_PINCM15)
/* Defines for BIN2: GPIOB.3 with pinCMx 16 on package pin 51 */
#define ABIN_BIN2_PIN                                            (DL_GPIO_PIN_3)
#define ABIN_BIN2_IOMUX                                          (IOMUX_PINCM16)
/* Port definition for Pin Group GW_GRAY */
#define GW_GRAY_PORT                                                     (GPIOA)

/* Defines for Key: GPIOA.27 with pinCMx 60 on package pin 31 */
#define GW_GRAY_Key_PIN                                         (DL_GPIO_PIN_27)
#define GW_GRAY_Key_IOMUX                                        (IOMUX_PINCM60)
/* Defines for CLK: GPIOA.7 with pinCMx 14 on package pin 49 */
#define GW_GRAY_CLK_PIN                                          (DL_GPIO_PIN_7)
#define GW_GRAY_CLK_IOMUX                                        (IOMUX_PINCM14)
/* Defines for DAT: GPIOA.2 with pinCMx 7 on package pin 42 */
#define GW_GRAY_DAT_PIN                                          (DL_GPIO_PIN_2)
#define GW_GRAY_DAT_IOMUX                                         (IOMUX_PINCM7)
/* Port definition for Pin Group SF_IIC1 */
#define SF_IIC1_PORT                                                     (GPIOA)

/* Defines for SDA: GPIOA.30 with pinCMx 5 on package pin 37 */
#define SF_IIC1_SDA_PIN                                         (DL_GPIO_PIN_30)
#define SF_IIC1_SDA_IOMUX                                         (IOMUX_PINCM5)
/* Defines for SCL: GPIOA.29 with pinCMx 4 on package pin 36 */
#define SF_IIC1_SCL_PIN                                         (DL_GPIO_PIN_29)
#define SF_IIC1_SCL_IOMUX                                         (IOMUX_PINCM4)
/* Port definition for Pin Group Stepper_Motor */
#define Stepper_Motor_PORT                                               (GPIOA)

/* Defines for DIR2: GPIOA.1 with pinCMx 2 on package pin 34 */
#define Stepper_Motor_DIR2_PIN                                   (DL_GPIO_PIN_1)
#define Stepper_Motor_DIR2_IOMUX                                  (IOMUX_PINCM2)
/* Defines for DIR1: GPIOA.16 with pinCMx 38 on package pin 9 */
#define Stepper_Motor_DIR1_PIN                                  (DL_GPIO_PIN_16)
#define Stepper_Motor_DIR1_IOMUX                                 (IOMUX_PINCM38)



/* clang-format on */

void SYSCFG_DL_init(void);
void SYSCFG_DL_initPower(void);
void SYSCFG_DL_GPIO_init(void);
void SYSCFG_DL_SYSCTL_init(void);
void SYSCFG_DL_PWM_A_init(void);
void SYSCFG_DL_PWM_B_init(void);
void SYSCFG_DL_TIMER_0_init(void);
void SYSCFG_DL_TIMER_1_init(void);
void SYSCFG_DL_UART_0_init(void);
void SYSCFG_DL_UART_WIT_init(void);
void SYSCFG_DL_UART_1_init(void);
void SYSCFG_DL_SPI_LCD_init(void);
void SYSCFG_DL_DMA_init(void);

void SYSCFG_DL_SYSTICK_init(void);

bool SYSCFG_DL_saveConfiguration(void);
bool SYSCFG_DL_restoreConfiguration(void);

#ifdef __cplusplus
}
#endif

#endif /* ti_msp_dl_config_h */
